package br.slic.util;

import java.util.Date;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class EmailUtil {

	public static void enviar(Session sessaoEmail, String emailPara, String assunto, String mensagem) {
		Message message = new MimeMessage(sessaoEmail);
		try {
			message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(emailPara, false));
			message.setSubject(assunto);
			message.setText(mensagem);
			message.setHeader("X-Mailer", "My Mailer");
			message.setSentDate(new Date());
			Transport.send(message);		
		} catch (AddressException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (MessagingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
